<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">工程名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">工程负责人</label>
                        <div class="layui-input-block">
                            <input type="text" name="gofuer" id="gofuer" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
<!--                                <div id="search_open" onclick="toggle_search()">-->
<!--                                    <i class="layui-icon layui-icon-down"></i>展开-->
<!--                                </div>-->
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
        <a href="javascript:;" class="bar_opt" onclick="auth_but_func_show('查看','{{d.LAY_TABLE_INDEX}}')">查看</a>
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>

    var param_gofuer = decodeURI(getQueryVariable('gofuer') || '') || '';
    $("#gofuer").val(param_gofuer);


    var currButAuth, currTabData;
    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;


        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });


        setSouTableExport('工程回款资金池');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_hou_chi_gonghui_list),where: {gofuer:param_gofuer}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text,totalRow: true
            ,parseData: function (res) {
                currButAuth = res.data.butauth;
                tableButShow(currButAuth);

                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            , cols: [[
                {type:'numbers',title:'序号',totalRowText: '合计',fixed:'left'}
                ,{field:'name',title:'工程名称',templet: function(d){
                    return '<span class="colorlan" onclick="openPage(\'../engin/show.php?id='+d.id+'\')">'+d.name+'</span>';
                }}
                ,{field:'shimoney',title:'合同价(元)',totalRow: true,templet: function(d){
                    if(d.shimoney){
                        return '<span class="colorlan" onclick="openPage(\'../contract_shi/show.php?id='+d.shiid+'\');">'+parseFormatNum(d.shimoney)+'</span>';
                    }else{
                        return '';
                    }
                }}
                ,{field:'shijiemoney',title:'工程累计结算金额(元)',totalRow: true,templet: function(d){
                    if(d.shijiemoney){
                        return '<span class="colorlan" onclick="openNavPage(\'施工合同结算信息\',\'contract_shi_jie/index.php?enginid='+d.id+'\');">'+parseFormatNum(d.shijiemoney)+'</span>';
                    }else{
                        return '';
                    }
                }}
                ,{field:'hougonghuimoney',title:'累计工程回款A(元)',totalRow: true,templet: function(d){
                    if(d.hougonghuimoney){
                        return '<span class="colorlan" onclick="openNavPage(\'工程回款信息\',\'hou_gonghui/index.php?enginid='+d.id+'\');">'+parseFormatNum(d.hougonghuimoney)+'</span>';
                    }else{
                        return '';
                    }
                }}
                ,{field:'hougongzhimoneyquben',title:'累计工程付款B(元)',totalRow: true,templet: function(d){
                    if(d.hougongzhimoneyquben){
                        return '<span class="colorlan" onclick="openNavPage(\'工程付款明细信息\',\'hou_chi_gongzhi/index.php?status=1&qu_enginid='+d.id+'\');">'+parseFormatNum(d.hougongzhimoneyquben)+'</span>';
                    }else{
                        return '';
                    }
                }}
                ,{field:'hougonghuikoufee',title:'累计已收取(元)C',totalRow: true,templet: function(d){
                        if(d.hougonghuikoufee){
                            return '<span class="colorlan" onclick="openNavPage(\'工程回款信息\',\'hou_gonghui/index.php?status=1&enginid='+d.id+'\');">'+parseFormatNum(d.hougonghuikoufee)+'</span>';
                        }else{
                            return '';
                        }
                    }}
                ,{field:'qizankoufee',title:'其中暂扣合计(元)',totalRow: true,templet: function(d){
                        if(d.qizankoufee){
                            return '<span class="colorlan" onclick="openNavPage(\'直接扣收明细信息\',\'hou_chi_kou_qifei/index.php?status=1&enginid='+d.id+'&kouxing='+encodeURI('暂扣')+'\');">'+parseFormatNum(d.qizankoufee)+'</span>';
                        }else{
                            return '';
                        }
                    }}
                ,{field:'jiedongkoufee',title:'暂扣解冻合计D(元)',totalRow: true,templet: function(d){
                        if(d.jiedongkoufee){
                            return '<span class="colorlan" onclick="openNavPage(\'直接收取信息\',\'hou_chi_kou_qifei/index.php?isdong=1&enginid='+d.id+'\');">'+parseFormatNum(d.jiedongkoufee)+'</span>';
                        }else{
                            return '';
                        }
                    }}
                ,{field:'yuliufee',title:'预留金额(元)',totalRow: true,templet: function(d){
                        return parseFormatNum(d.yuliufee);
                    }}
                ,{field:'hougonghuikeyong',title:'工程回款可用余额A-B-C+D(元)',totalRow: true,templet: function(d){
                        return parseFormatNum(d.hougonghuikeyong);
                    }}
                ,{field: 'number', title: '工程编号'}
                ,{field: 'gofuer', title: '工程负责人'}
                ,{field: 'state_name', title: '工程状态'}
                ,{field: 'gui_unit_name', title: '业务归属'}
            ]]
            , done: function (res) {
                soulTable.render(this);

                currTabData = res.data;
                $.each(currTabData, function(index,item){
                    var chk = $('tr[data-index=' + item.LAY_TABLE_INDEX + '] .tab-list-authbut');
                    for (var key in currButAuth) {
                        if(currButAuth[key].pagetype === 0 || currButAuth[key].pagetype === 1){
                            chk.append(' <a ' +
                                'href="javascript:;" ' +
                                'class="bar_opt layui-hide" ' +
                                'lay-event="search" ' +
                                'data-butname="'+currButAuth[key].butname+'" ' +
                                'data-title="'+currButAuth[key].title+'" ' +
                                'onclick="auth_but_func_'+currButAuth[key].butname+'(\''+currButAuth[key].title+'\', '+index+')"' +
                                '>'+currButAuth[key].title+'' +
                                '</a>');
                        }
                    }
                });
                show_tab_but(currTabData);
            }
        });


        listTableSearch(form, table);
    });

</script>
</body>
</html>
